<?php
/**
 * NOTICE OF LICENSE
 *
 * This source file is subject to the  Academic Free License (AFL 3.0)
 * that is available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to support@zprofess.com so we can send you a copy immediately.
 *
 * @category   	Prestashop module
 * @package		Review & Rating Synthesis
 * @version 	1.0.2
 * @author 		Rukan <rukanhitokiri@zprofess.com>
 * @copyright   Copyright (c) 2012 ZPROFESS. (http://www.zprofess.com)
 * @license    	http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

class ZprofessConfigure extends ModuleCore
{
	/** @var max image size */
	protected $maxImageSize = 307200;
	
	public static $configRating = array();
	
	public function __construct($name = NULL)
	{
		parent::__construct();
		$this->_path = __PS_BASE_URI__.'modules/reviewratingsynthesis/';
	}
	
	private function _get($key) 
	{
		$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
			SELECT value FROM '._DB_PREFIX_.'configuration 			
			WHERE name="'.$key.'" 
		');
		return $result;
	}
	
	/**
	 * display Support
	 * 
     * @return string
	 */
	private function _displaySupport()
	{
		$this->_html .= '
 		<fieldset><legend><img src="'.$this->_path.'logo.gif" /> '.$this->l('Support').'</legend>
			<img src="'.$this->_path.'img/logo.jpg" style="float:right;margin-left:10px" />
			<br />
			'.$this->l('The full installation guide is available on').' <a href="http://zprofess.com" target="_blank" style="text-decoration:underline">'.$this->l('the official Zprofess website').'</a>.
			<br /><br />
			'.$this->l('Find more information at').' <a href="http://zprofess.com" target="_blank" style="text-decoration:underline">'.$this->l('http://zprofess.com').'</a>.
		</fieldset>
		<div class="clear">&nbsp;</div>';
	}
	
	/**
	 * display Form Config (All tab)
	 * 
     * @return string
	 */
	private function _displayFormConfig()
	{
		$this->_html .= '
		<ul id="menuTab">
				<li id="menuTab1" class="menuTabButton selected">1. '.$this->l('General Settings').'</li>
				<li id="menuTab2" class="menuTabButton">2. '.$this->l('Rating Settings').'</li>
				<li id="menuTab3" class="menuTabButton">3. '.$this->l('Review Settings').'</li>
				<li id="menuTab4" class="menuTabButton">4. '.$this->l('Captcha Settings').'</li>
				<li id="menuTab5" class="menuTabButton">5. '.$this->l('Email Settings').'</li>
				<li id="menuTab6" class="menuTabButton">6. '.$this->l('Help').'</li>
			</ul>
			<div id="tabList">
				<div id="menuTab1Sheet" class="tabItem selected">'.$this->_displayFormGeneral().'</div>
				<div id="menuTab2Sheet" class="tabItem">'.$this->_displayFormRating().'</div>
				<div id="menuTab3Sheet" class="tabItem">'.$this->_displayFormReview().'</div>
				<div id="menuTab4Sheet" class="tabItem">'.$this->_displayFormCaptcha().'</div>
				<div id="menuTab5Sheet" class="tabItem">'.$this->_displayFormEmail().'</div>
				<div id="menuTab6Sheet" class="tabItem">'.$this->_displayHelp().'</div>
			</div>
			<br clear="left" />
			<br />
			<style>
			    #menuTab { float: left; padding: 0; margin: 0; text-align: left; }
				#menuTab li { text-align: left; float: left; display: inline; padding: 5px; padding-right: 10px; background: #EFEFEF; font-weight: bold; cursor: pointer; border-left: 1px solid #EFEFEF; border-right: 1px solid #EFEFEF; border-top: 1px solid #EFEFEF; }
				#menuTab li.menuTabButton.selected { background: #FFF6D3; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; }
				#tabList { clear: left; }
				.tabItem { display: none; }
				.tabItem.selected { display: block; background: #FFFFF0; border: 1px solid #CCCCCC; padding: 10px; padding-top: 20px; }
			</style>
			<script>
				$(".menuTabButton").click(function () {
				  $(".menuTabButton.selected").removeClass("selected");
				  $(this).addClass("selected");
				  $(".tabItem.selected").removeClass("selected");
				  $("#" + this.id + "Sheet").addClass("selected");
				});
			</script>
		';
		if (isset($_GET['id_tab']))
			$this->_html .= '<script>
				  $(".menuTabButton.selected").removeClass("selected");
				  $("#menuTab'.Tools::getValue('id_tab').'").addClass("selected");
				  $(".tabItem.selected").removeClass("selected");
				  $("#menuTab'.Tools::getValue('id_tab').'Sheet").addClass("selected");
			</script>';
	}
	
	/**
	 * Display form General Settings
	 * 
	 * @return string
	 */
	private function _displayFormGeneral()
	{
		return '
		<form action="index.php?tab='.Tools::getValue('tab').'&configure='.Tools::getValue('configure').'&token='.Tools::getValue('token').'&tab_module='.Tools::getValue('tab_module').'&module_name='.Tools::getValue('module_name').'&id_tab=1" method="post">
			<fieldset style="float:left;width:400px;margin-right:20px;">
				<legend><img src="../img/admin/cog.gif"/>'.$this->l('General Settings').'</legend>
				
				<label style="padding-top: 0;">'.$this->l('All reviews & ratings must be validated by an employee').'</label>
				<div class="margin-form">
					<input type="radio" name="validated" id="validated_on" value="1" '.(Configuration::get('ZPRO_VALIDATED_BY_EMPLOYEE') ? 'checked="checked" ' : '').'/>
					<label class="t" for="validated_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
					<input type="radio" name="validated" id="validated_off" value="0" '.(!Configuration::get('ZPRO_VALIDATED_BY_EMPLOYEE') ? 'checked="checked" ' : '').'/>
					<label class="t" for="validated_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
				</div>
				<div class="clear" style="height: 10px;"></div>
				
				<label style="padding-top: 0;">'.$this->l('Allow guest reviews & ratings').'</label>
				<div class="margin-form">
					<input type="radio" name="allow_guest" id="allow_guest_on" value="1" '.(Configuration::get('ZPRO_ALLOW_GUESTS') ? 'checked="checked" ' : '').'/>
					<label class="t" for="allow_guest_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
					<input type="radio" name="allow_guest" id="allow_guest_off" value="0" '.(!Configuration::get('ZPRO_ALLOW_GUESTS') ? 'checked="checked" ' : '').'/>
					<label class="t" for="allow_guest_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
				</div>
				<div class="clear"></div>
				
				<label style="padding-top: 0;">'.$this->l('Minimum time between 2 reviews & ratings from the same user').'</label>
				<div class="margin-form">
					<input name="minimal_time" type="text" class="text" value="'.Configuration::get('ZPRO_MINIMAL_TIME').'" style="width: 40px; text-align: right;" /> '.$this->l('seconds').'
					<p class="clear">'.$this->l('Leave blank for disabling').'</p>
				</div>
				
				<label style="padding-top: 0;">'.$this->l('Just text reviews alone, no rating').'</label>
				<div class="margin-form">
					<input type="radio" name="only_review" id="only_review_on" value="1" '.(Configuration::get('ZPRO_ONLY_REVIEW') ? 'checked="checked" ' : '').'/>
					<label class="t" for="only_review_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
					<input type="radio" name="only_review" id="only_review_off" value="0" '.(!Configuration::get('ZPRO_ONLY_REVIEW') ? 'checked="checked" ' : '').'/>
					<label class="t" for="only_review_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
				</div>
				<div class="clear"></div>
				
				<label>'.$this->l('Position of rating in product view page').' </label>
				<div class="margin-form">
					<select name="hook_rating">
					  	<option value="0" '.(Configuration::get('ZPRO_HOOK_RATING') == 0 ? 'selected="selected" ' : '').'>None</option>
					  	<option value="1" '.(Configuration::get('ZPRO_HOOK_RATING') == 1 ? 'selected="selected" ' : '').'>Below add to cart button</option>
					  	<option value="2" '.(Configuration::get('ZPRO_HOOK_RATING') == 2 ? 'selected="selected" ' : '').'>Below product image</option>
					 	<option value="4" '.(Configuration::get('ZPRO_HOOK_RATING') == 4 ? 'selected="selected" ' : '').'>Positioning to the bottom left</option>
					</select>
				</div>
				<div class="clear"></div>
				
				<label>'.$this->l('Display latest reviews').' </label>
				<div class="margin-form">
					<select name="latest_reviews">
					  	<option value="0" '.(Configuration::get('ZPRO_HOOK_LATEST_REVIEWS') == 0 ? 'selected="selected" ' : '').'>None</option>
					  	<option value="1" '.(Configuration::get('ZPRO_HOOK_LATEST_REVIEWS') == 1 ? 'selected="selected" ' : '').'>Home page</option>
					  	<option value="2" '.(Configuration::get('ZPRO_HOOK_LATEST_REVIEWS') == 2 ? 'selected="selected" ' : '').'>Left column</option>
					  	<option value="3" '.(Configuration::get('ZPRO_HOOK_LATEST_REVIEWS') == 3 ? 'selected="selected" ' : '').'>Right column</option>
					</select>
				</div>
				<div class="clear"></div> 
				
				<label style="padding-top: 0;">'.$this->l('The number of final reviews & ratings show').'</label>
				<div class="margin-form">
					<input name="number_latest_reviews" type="text" class="text" value="'.Configuration::get('ZPRO_NUMBER_LATEST_REVIEWS').'" style="width: 40px; text-align: right;" />
				</div>
				<div class="clear"></div> 
				
				<label style="padding-top: 0;">'.$this->l('Facebook share button').'</label>
				<div class="margin-form">
					<input type="radio" name="fb_share" id="fb_share_on" value="1" '.(Configuration::get('ZPRO_FB_SHARE') ? 'checked="checked" ' : '').'/>
					<label class="t" for="fb_share_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
					<input type="radio" name="fb_share" id="fb_share_off" value="0" '.(!Configuration::get('ZPRO_FB_SHARE') ? 'checked="checked" ' : '').'/>
					<label class="t" for="fb_share_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
				</div>
				<div class="clear"></div>
			</fieldset>	
			<fieldset style="float:left;width:400px">
				<legend><img src="../img/admin/cog.gif"/>'.$this->l('Vote Settings').'</legend>
				
				<label style="padding-top: 0;">'.$this->l('Enable vote').'</label>
				<div class="margin-form">
					<input type="radio" name="enable_vote" id="enable_vote_on" value="1" '.(Configuration::get('ZPRO_ENABLE_VOTE') ? 'checked="checked" ' : '').'/>
					<label class="t" for="enable_vote_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
					<input type="radio" name="enable_vote" id="enable_vote_off" value="0" '.(!Configuration::get('ZPRO_ENABLE_VOTE') ? 'checked="checked" ' : '').'/>
					<label class="t" for="enable_vote_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
				</div>
				<div class="clear"></div>
				
				<label>'.$this->l('Display like most').' </label>
				<div class="margin-form">
					<select name="vote_most">
					  	<option value="0" '.(Configuration::get('ZPRO_HOOK_VOTE_MOST') == 0 ? 'selected="selected" ' : '').'>None</option>
					  	<option value="2" '.(Configuration::get('ZPRO_HOOK_VOTE_MOST') == 2 ? 'selected="selected" ' : '').'>Left column</option>
					  	<option value="3" '.(Configuration::get('ZPRO_HOOK_VOTE_MOST') == 3 ? 'selected="selected" ' : '').'>Right column</option>
					</select>
				</div>
				<div class="clear"></div> 
				
				<label style="padding-top: 0;">'.$this->l('The number of final like show').'</label>
				<div class="margin-form">
					<input name="number_vote_most" type="text" class="text" value="'.Configuration::get('ZPRO_NUMBER_VOTE_MOST').'" style="width: 40px; text-align: right;" />
				</div>
				<div class="clear"></div>
			</fieldset>
			<div class="clear"></div>
			<hr size="1" noshade />
			<center><input type="submit" name="submitGeneralSettings" value="'.$this->l('Save').'" class="button" /></center>
		</form>
		<div class="clear"></div>';
	}
	
	private function _renderJS()
	{
		self::getRatingConfig();
		
		$html = '
		<script type="text/javascript" src="'.$this->_path.'js/raty/jquery.raty.min.js"></script>
		<script type="text/javascript">
			$(document).ready(function(){
				$(".custom").raty({
					width: 			'.self::$configRating['width'].',
					cancel: 		'.self::$configRating['cancel'].',							
					cancelHint:   	"'.self::$configRating['cancelHint'].'",  
					cancelOff:  	"'.self::$configRating['cancelOff'].'",
					cancelOn:   	"'.self::$configRating['cancelOn'].'", 	
					cancelPlace:  	"'.self::$configRating['cancelPlace'].'", 
				
					half:  			'.self::$configRating['half'].',
					hintList:		'.self::$configRating['hintList'].',
					noRatedMsg:		"'.self::$configRating['noRatedMsg'].'",
					number:     	'.self::$configRating['number'].',
					path:           "'.self::$configRating['path'].'",	
					iconRange:      '.self::$configRating['iconRange'].',
					starHalf:		"'.self::$configRating['starHalf'].'",
					starOff:		"'.self::$configRating['starOff'].'",
					starOn:			"'.self::$configRating['starOn'].'",					
					start: 			'.self::$configRating['start'].',
				});
				
				$(".star").raty({
					path:         	"'.$this->_path.'img/raty/",
					start: 			3,
				});
				
				$(".big_star").raty({
					cancelOff:  	"cancel-off-big.png",
					cancelOn:   	"cancel-on-big.png",
					path:         	"'.$this->_path.'img/raty/",
					width: 			160,
					start: 			3,
					starOff:    	"star-off-big.png",
					starOn:     	"star-on-big.png",
				});
				
				$(".medal").raty({
					path:         	"'.$this->_path.'img/raty/",
					start: 			3,													
  					starOn:    		"medal-on.png",
  					starOff:   		"medal-off.png",
				});
				
				$(".face").raty({
					path:         	"'.$this->_path.'img/raty/",												
					iconRange: [["face-a.png", 2], ["face-b.png", 3], ["face-c.png", 4], ["face-d.png", 5]],
					starOff:   "face-off.png",
				});
			}); 
		</script>';
		return $html;
	}
	
	/**
	 * Display form Rating Settings
	 * 
	 * @return string
	 */
	private function _displayFormRating()
	{
		$html = $this->_renderJS().'
		<form action="index.php?tab='.Tools::getValue('tab').'&configure='.Tools::getValue('configure').'&token='.Tools::getValue('token').'&tab_module='.Tools::getValue('tab_module').'&module_name='.Tools::getValue('module_name').'&id_tab=2" method="post" enctype="multipart/form-data">
			<fieldset class="width2" style="float:left;">
				<legend><img src="'.$this->_path.'logo.gif"/>'.$this->l('Rating Settings').'</legend>
				
				<label style="padding-top: 0;">'.$this->l('Number of stars that will be presented').'</label>
				<div class="margin-form">
					<input name="number" type="text" class="text" value="'.Configuration::get('ZPRO_NUMBER').'" style="width:40px;text-align:right;" />
				</div>
				<div class="clear"></div>
				
				<label style="padding-top: 0;">'.$this->l('Number of stars to be selected').'</label>
				<div class="margin-form">
					<input name="start" type="text" class="text" value="'.Configuration::get('ZPRO_START').'" style="width:40px;text-align:right;" />
				</div>
				<div class="clear"></div>
				
				<label style="padding-top: 0;">'.$this->l('Enable half star').'</label>
				<div class="margin-form">
					<input type="radio" name="half" id="half_on" value="1" '.(Configuration::get('ZPRO_HALF') ? 'checked="checked" ' : '').'/>
					<label class="t" for="half_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
					<input type="radio" name="half" id="half_off" value="0" '.(!Configuration::get('ZPRO_HALF') ? 'checked="checked" ' : '').'/>
					<label class="t" for="half_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
					<p class="clear">The interval can be: <br />
									 - Rounded down: [x.00 ... x.25] <br />
									 - Half star:    [x.26 ... x.75] <br />
									 - Rounded up:   [x.76 ... x.99] <br /> 
					</p>
				</div>
				<div class="clear"></div>
				
				<label style="padding-top: 0;">'.$this->l('List of names that will be used as a hint on each star').'</label>
				<div class="margin-form">
					<input name="hint_list" type="text" class="text" value="'.Configuration::get('ZPRO_HINT_LIST').'" style="width:280px;" />
					<p class="clear">Hints separated by commas (e.g., bad, regular, good)</p>
				</div>
				
				<label style="padding-top: 0;">'.$this->l('The container width of the stars').'</label>
				<div class="margin-form">
					<input name="width" type="text" class="text" value="'.Configuration::get('ZPRO_WIDTH').'" style="width:40px;text-align:right;" /> px
					<p class="clear">Leave blank for disabling</p>
				</div>
				
				<label for="store_img">'.$this->l('Change the star image off').'</label>
				<div class="margin-form">';
					if (file_exists(dirname(__FILE__).'/../img/'.Configuration::get('ZPRO_STAR_OFF')))
						$html .= '<div id="image" >
									<img src="'.$this->_path.'img/'.Configuration::get('ZPRO_STAR_OFF').'?t='.time().'" />
									<p align="center">'.$this->l('Filesize').' '.(filesize(dirname(__FILE__).'/../img/'.Configuration::get('ZPRO_STAR_OFF')) / 1000).'kb</p>
								  </div>';
						
				$html .= '		  <input id="star_off" type="file" name="star_off" '.(Configuration::get('ZPRO_RATING_STYLE') == 4 ? 'style="display:none;"' : '').'/>
								 <div class="clear">'.(Configuration::get('ZPRO_RATING_STYLE') == 4 ? '( only used )' : '').'</div>
				</div>
				
				<div '.(Configuration::get('ZPRO_RATING_STYLE') == 4 ? 'style="display:none;"' : '').'>
					<label for="store_img">'.$this->l('Change the star image on').'</label>
					<div class="margin-form">';
						if (file_exists(dirname(__FILE__).'/../img/'.Configuration::get('ZPRO_STAR_ON')))
							$html .= '<div id="image" >
										<img src="'.$this->_path.'img/'.Configuration::get('ZPRO_STAR_ON').'?t='.time().'" />
										<p align="center">'.$this->l('Filesize').' '.(filesize(dirname(__FILE__).'/../img/'.Configuration::get('ZPRO_STAR_ON')) / 1000).'kb</p>
									  </div>';
					$html .= '<input id="star_on" type="file" name="star_on" />
					</div>
					<div class="clear"></div>
				</div>
				
				<div '.(Configuration::get('ZPRO_RATING_STYLE') == 4 ? 'style="display:none;"' : '').'>
					<label for="store_img">'.$this->l('Change the half star image').'</label>
					<div class="margin-form">';
						if (file_exists(dirname(__FILE__).'/../img/'.Configuration::get('ZPRO_STAR_HALF')))
							$html .= '<div id="image" >
										<img src="'.$this->_path.'img/'.Configuration::get('ZPRO_STAR_HALF').'?t='.time().'" />
										<p align="center">'.$this->l('Filesize').' '.(filesize(dirname(__FILE__).'/../img/'.Configuration::get('ZPRO_STAR_HALF')) / 1000).'kb</p>
									  </div>';
					$html .= '	<input id="star_half" type="file" name="star_half" />
					</div>
					<div class="clear"></div>
				</div>
				
				<hr size="1" noshade />
				
				<label style="padding-top: 0;">'.$this->l('Cancel button').'</label>
				<div class="margin-form">
					<input type="radio" name="cancel" id="cancel_on" value="1" '.(Configuration::get('ZPRO_CANCEL') ? 'checked="checked" ' : '').'/>
					<label class="t" for="cancel_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
					<input type="radio" name="cancel" id="cancel_off" value="0" '.(!Configuration::get('ZPRO_CANCEL') ? 'checked="checked" ' : '').'/>
					<label class="t" for="cancel_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
					<p class="clear">If enabled will be showed a button to cancel the rating</p>
				</div>
				
				<label style="padding-top: 0;">'.$this->l('The hint information of the cancel hint').'</label>
				<div class="margin-form">
					<input name="cancel_hint" type="text" class="text" value="'.Configuration::get('ZPRO_CANCEL_HINT').'" style="width:280px;" />
				</div>
				<div class="clear"></div>
				
				<label style="vertical-align: middle;">'.$this->l('Position of the cancel button').'</label>
				<div class="margin-form" style="margin-top: 5px;">
					<input type="radio" name="cancel_place" value="1" style="vertical-align: middle;" '.(Configuration::get('ZPRO_CANCEL_PLACE') ? 'checked="checked" ' : '').'/> '.$this->l('Left').'&nbsp;
					<input type="radio" name="cancel_place" value="0" style="vertical-align: middle;" '.(!Configuration::get('ZPRO_CANCEL_PLACE') ? 'checked="checked" ' : '').'/> '.$this->l('Right').'
				</div>
				<div class="clear"></div>
				
				<label for="store_img">'.$this->l('Change the cancel image off').'</label>
				<div class="margin-form">';
					if (file_exists(dirname(__FILE__).'/../img/'.Configuration::get('ZPRO_CANCEL_OFF')))
						$html .= '<div id="image" >
									<img src="'.$this->_path.'img/'.Configuration::get('ZPRO_CANCEL_OFF').'?t='.time().'" />
									<p align="center">'.$this->l('Filesize').' '.(filesize(dirname(__FILE__).'/../img/'.Configuration::get('ZPRO_CANCEL_OFF')) / 1000).'kb</p>
								  </div>';
				$html .= '	<input id="cancel_off" type="file" name="cancel_off" />
				</div>
				<div class="clear"></div>
				
				<label for="store_img">'.$this->l('Change the cancel image on').'</label>
				<div class="margin-form">';
					if (file_exists(dirname(__FILE__).'/../img/'.Configuration::get('ZPRO_CANCEL_ON')))
						$html .= '<div id="image" >
									<img src="'.$this->_path.'img/'.Configuration::get('ZPRO_CANCEL_ON').'?t='.time().'" />
									<p align="center">'.$this->l('Filesize').' '.(filesize(dirname(__FILE__).'/../img/'.Configuration::get('ZPRO_CANCEL_ON')) / 1000).'kb</p>
								  </div>';
				$html .= '	<input id="cancel_on" type="file" name="cancel_on" />
				</div>
				<div class="clear"></div>
				
				<hr size="1" noshade />
				<center><input type="submit" class="button" value="Save" name="submitRatingSettings"></center>
			</fieldset>
		</form>
		<form action="index.php?tab='.Tools::getValue('tab').'&configure='.Tools::getValue('configure').'&token='.Tools::getValue('token').'&tab_module='.Tools::getValue('tab_module').'&module_name='.Tools::getValue('module_name').'&id_tab=2" method="post">
			<div style="float:left;margin:10px 0 0 30px;">
				<p><b>'.$this->l('Review custom').'</b></p>
				<div class="custom" id="custom" style="border-bottom:1px solid #DEDEDE;margin-bottom:25px;"></div>
				
				<p><input type="radio" name="style" id="style" value="1" '.(Configuration::get('ZPRO_RATING_STYLE')==1 ? 'checked="checked" ' : '').'/>
				   <b>'.$this->l('Star').'</b></p>
				<div class="star" id="star" style="margin-bottom:25px;"></div>
				
				<p><input type="radio" name="style" id="style" value="2" '.(Configuration::get('ZPRO_RATING_STYLE')==2 ? 'checked="checked" ' : '').'/>
				   <b>'.$this->l('Big star').'</b></p>
				<div class="big_star" id="big_star" style="margin-bottom:25px;"></div>
				
				<p><input type="radio" name="style" id="style" value="3" '.(Configuration::get('ZPRO_RATING_STYLE')==3 ? 'checked="checked" ' : '').'/>
				   <b>'.$this->l('Medal').'</b></p>
				<div class="medal" id="medal" style="margin-bottom:25px;"></div>
				
				<div style="display:none;">
					<p><input type="radio" name="style" id="style" value="4" '.(Configuration::get('ZPRO_RATING_STYLE')==4 ? 'checked="checked" ' : '').'/>
					   <b>'.$this->l('Face (some feature is only used)').'</b></p>
					<div class="face" id="face" style="margin-bottom:25px;"></div>
				</div>
				
				<hr size="1" noshade style="width:333px;" />
				<center><input type="submit" class="button" value="Save" name="submitRatingStyle"></center>
			</div>
			<div class="clear"></div>
		</form>';
		return $html;
	}
	
	/**
	 * display Form Review
	 * 
     * @return string
	 */
	private function _displayFormReview()
	{
		return '
		<form action="index.php?tab='.Tools::getValue('tab').'&configure='.Tools::getValue('configure').'&token='.Tools::getValue('token').'&tab_module='.Tools::getValue('tab_module').'&module_name='.Tools::getValue('module_name').'&id_tab=3" method="post">
			<fieldset style="float:left;width:431px">
				<legend><img src="../img/admin/comment.gif"/>'.$this->l('Review Settings').'</legend>
				<p><img src="../img/admin/duplicate.gif" alt="" /> '.$this->l('Set fields you would like to display in review form').'</p>
				<label style="padding-top: 0;">'.$this->l('Email').'</label>
				<div class="margin-form">
					<input type="radio" name="enable_email" id="enable_email_on" value="1" '.(Configuration::get('ZPRO_ENABLE_EMAIL') ? 'checked="checked" ' : '').'/>
					<label class="t" for="enable_email_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
					<input type="radio" name="enable_email" id="enable_email_off" value="0" '.(!Configuration::get('ZPRO_ENABLE_EMAIL') ? 'checked="checked" ' : '').'/>
					<label class="t" for="enable_email_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
					<p class="clear">Only display field when customer no login</p>
				</div>
				<div class="clear"></div>
				
				<label style="padding-top: 0;">'.$this->l('Website').'</label>
				<div class="margin-form">
					<input type="radio" name="enable_website" id="enable_website_on" value="1" '.(Configuration::get('ZPRO_ENABLE_WEBSITE') ? 'checked="checked" ' : '').'/>
					<label class="t" for="enable_website_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
					<input type="radio" name="enable_website" id="enable_website_off" value="0" '.(!Configuration::get('ZPRO_ENABLE_WEBSITE') ? 'checked="checked" ' : '').'/>
					<label class="t" for="enable_website_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
				</div>
				<div class="clear"></div>
				
				<hr size="1" noshade="">
				
				<p><img src="../img/admin/duplicate.gif" alt="" /> '.$this->l('Set fields you would like to display in review list').'</p>
				<div class="requiredFieldsParameters">
					<label style="padding-top: 0;">'.$this->l('Email').'</label>
					<div class="margin-form">
						<input type="radio" name="display_email" id="display_email_on" value="1" '.(Configuration::get('ZPRO_DISPLAY_EMAIL') ? 'checked="checked" ' : '').'/>
						<label class="t" for="display_email_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
						<input type="radio" name="display_email" id="display_email_off" value="0" '.(!Configuration::get('ZPRO_DISPLAY_EMAIL') ? 'checked="checked" ' : '').'/>
						<label class="t" for="display_email_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
					</div>
					<div class="clear"></div>
					
					<label style="padding-top: 0;">'.$this->l('Website').'</label>
					<div class="margin-form">
						<input type="radio" name="display_website" id="display_website_on" value="1" '.(Configuration::get('ZPRO_DISPLAY_WEBSITE') ? 'checked="checked" ' : '').'/>
						<label class="t" for="display_website_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
						<input type="radio" name="display_website" id="display_website_off" value="0" '.(!Configuration::get('ZPRO_DISPLAY_WEBSITE') ? 'checked="checked" ' : '').'/>
						<label class="t" for="display_website_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
					</div>
					<div class="clear"></div>
					
					<label style="padding-top: 0;">'.$this->l('Title').'</label>
					<div class="margin-form">
						<input type="radio" name="display_title" id="display_title_on" value="1" '.(Configuration::get('ZPRO_DISPLAY_TITLE') ? 'checked="checked" ' : '').'/>
						<label class="t" for="display_title_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
						<input type="radio" name="display_title" id="display_title_off" value="0" '.(!Configuration::get('ZPRO_DISPLAY_TITLE') ? 'checked="checked" ' : '').'/>
						<label class="t" for="display_title_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
					</div>
					<div class="clear"></div>
				</div>
				
				<hr size="1" noshade />
				<center><input type="submit" name="submitReviewSettings" value="'.$this->l('Save').'" class="button" /></center>
			</fieldset>		
		</form>
		<div class="clear"></div>
		';
	}
	
	/**
	 * Display form Captcha Settings
	 * 
	 * @return string
	 */
	private function _displayFormCaptcha()
	{
		return '
		<form action="index.php?tab='.Tools::getValue('tab').'&configure='.Tools::getValue('configure').'&token='.Tools::getValue('token').'&tab_module='.Tools::getValue('tab_module').'&module_name='.Tools::getValue('module_name').'&id_tab=4" method="post">
			<fieldset style="float:left;width:400px">
				<legend><img src="../img/admin/cog.gif"/>'.$this->l('Captcha Settings').'</legend>
				
				<label style="padding-top: 0;">'.$this->l('Enable Captcha in review form').'</label>
				<div class="margin-form">
					<input type="radio" name="enable_captcha" id="enable_captcha_on" value="1" '.(Configuration::get('ZPRO_ENABLE_CAPTCHA') ? 'checked="checked" ' : '').'/>
					<label class="t" for="enable_captcha_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
					<input type="radio" name="enable_captcha" id="enable_captcha_off" value="0" '.(!Configuration::get('ZPRO_ENABLE_CAPTCHA') ? 'checked="checked" ' : '').'/>
					<label class="t" for="enable_captcha_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
				</div>
				<div class="clear"></div>
				
				<hr size="1" noshade="">
				
				<label style="padding-top: 0;">'.$this->l('Height of the captcha image').'</label>
				<div class="margin-form">
					<input name="height_img" type="text" class="text" value="'.Configuration::get('ZPRO_HEIGHT_IMG').'" style="width: 40px; text-align: right;" />
				</div>
				<div class="clear"></div>
				
				<label style="padding-top: 0;">'.$this->l('Width of the captcha image').'</label>
				<div class="margin-form">
					<input name="width_img" type="text" class="text" value="'.Configuration::get('ZPRO_WIDTH_IMG').'" style="width: 40px; text-align: right;" />
				</div>
				<div class="clear"></div>
				
				<hr size="1" noshade="">
				
				<script type="text/javascript" src="'._PS_JS_DIR_.'/jquery/jquery-colorpicker.js"></script>
				<label style="padding-top: 0;">'.$this->l('Background color').'</label>
				<div class="margin-form">
					<input type="color" width="50px" data-hex="true" class="color mColorPickerInput" name="bg_color" value="'.htmlentities(Configuration::get('ZPRO_BG_COLOR'), ENT_COMPAT, 'UTF-8').'" />
				</div>
				<div class="clear"></div>
				
				<label style="padding-top: 0;">'.$this->l('Text color').'</label>
				<div class="margin-form">
					<input type="color" width="50px" data-hex="true" class="color mColorPickerInput" name="text_color" value="'.Configuration::get('ZPRO_TEXT_COLOR').'" />
				</div>
				<div class="clear"></div>
				
				<label style="padding-top: 0;">'.$this->l('Line color').'</label>
				<div class="margin-form">
					<input type="color" width="50px" data-hex="true" class="color mColorPickerInput" name="line_color" value="'.Configuration::get('ZPRO_LINE_COLOR').'" />
				</div>
				<div class="clear"></div>
				
				<hr size="1" noshade="">
				
				<label style="padding-top: 0;">'.$this->l('Code length').'</label>
				<div class="margin-form">
					<input name="code_length" type="text" class="text" value="'.Configuration::get('ZPRO_CODE_LENGTH').'" style="width: 40px; text-align: right;" />
				</div>
				<div class="clear"></div>
				
				<label style="padding-top: 0;">'.$this->l('Number lines drawing over the image').'</label>
				<div class="margin-form">
					<input name="number_line" type="text" class="text" value="'.Configuration::get('ZPRO_NUMBER_LINE').'" style="width: 40px; text-align: right;" />
				</div>
				<div class="clear"></div>
				
				<hr size="1" noshade="">

				<label style="padding-top: 0;">'.$this->l('Signature text').'</label>
				<div class="margin-form">
					<input name="signature_text" type="text" class="text" value="'.Configuration::get('ZPRO_SIGNATURE_TEXT').'" style="text-align: right;" />
				</div>
				<div class="clear"></div>
				
				<label style="padding-top: 0;">'.$this->l('Signature color').'</label>
				<div class="margin-form">
					<input type="color" width="50px" data-hex="true" class="color mColorPickerInput" name="signature_color" value="'.htmlentities(Configuration::get('ZPRO_SIGNATURE_COLOR'), ENT_COMPAT, 'UTF-8').'" />
				</div>
				<div class="clear"></div>
				
				<hr size="1" noshade />
				<center><input type="submit" name="submitCaptchaSettings" value="'.$this->l('Save').'" class="button" /></center>
			</fieldset>		
		</form>
		<div class="clear"></div>';
	}
	
	/**
	 * Display form Email Settings
	 * 
	 * @return string
	 */
	private function _displayFormEmail()
	{
		// TinyMCE
		global $cookie;
		$iso = Language::getIsoById((int)($cookie->id_lang));
		$isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$iso.'.js') ? $iso : 'en');
		$ad = dirname($_SERVER["PHP_SELF"]);
		$mce = '
			<script type="text/javascript">	
			var iso = \''.$isoTinyMCE.'\' ;
			var pathCSS = \''._THEME_CSS_DIR_.'\' ;
			var ad = \''.$ad.'\' ;
			</script>
			<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tiny_mce/tiny_mce.js"></script>
			<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tinymce.inc.js"></script>';
		
		return $mce.'
		<form action="index.php?tab='.Tools::getValue('tab').'&configure='.Tools::getValue('configure').'&token='.Tools::getValue('token').'&tab_module='.Tools::getValue('tab_module').'&module_name='.Tools::getValue('module_name').'&id_tab=5" method="post">
			<fieldset style="float:left;width:800px">
				<legend><img src="../img/admin/cog.gif"/>'.$this->l('Email Settings').'</legend>
				
				<label style="padding-top: 0;">'.$this->l('Enable').'</label>
				<div class="margin-form">
					<input type="radio" name="enable_email_notification" id="enable_email_notification_on" value="1" '.(Configuration::get('ZPRO_ENABLE_EMAIL_NOTIFICATION') ? 'checked="checked" ' : '').'/>
					<label class="t" for="enable_email_notification_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
					<input type="radio" name="enable_email_notification" id="enable_email_notification_off" value="0" '.(!Configuration::get('ZPRO_ENABLE_EMAIL_NOTIFICATION') ? 'checked="checked" ' : '').'/>
					<label class="t" for="enable_email_notification_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
					<p class="clear">Email notifications for administrator when users post a new reviews & ratings</p>
				</div>
				
				<label style="padding-top: 0;">'.$this->l('Email Notification').'</label>
				<div class="margin-form">
					<input name="email_notification" type="text" class="text" value="'.Configuration::get('ZPRO_EMAIL_NOTIFICATION').'" style="width: 200px;" />
				</div>
				<div class="clear"></div>
				
				<label style="padding-top: 0;">'.$this->l('Subject').'</label>
				<div class="margin-form">
					<input style="width:545px;" type="text" value="'.(Configuration::get('ZPRO_EMAIL_SUBJECT')).'" name="email_subject" id="email_subject"/>
				</div>	
				<div class="clear"></div>
				
				<label style="padding-top: 0;">'.$this->l('Email template').'</label>
				<div class="margin-form">
					<textarea class="rte" cols="100" rows="5" name="email_tempalte" >'.htmlentities($this->_get('ZPRO_EMAIL_TEMPLATE'), ENT_COMPAT, 'UTF-8').'</textarea>
					<p class="clear">template variable specifies<br/>
						{product_name}: '.$this->l("Product Name").' <br/>
						{email}: '.$this->l("Customer Email").' <br/>
						{customer_name}: '.$this->l("Customer name").' <br/>
						{content}: '.$this->l("Content review").' <br/>
					</p>
				</div>
				
				<hr size="1" noshade />
				<center><input type="submit" name="submitEmailSettings" value="'.$this->l('Save').'" class="button" /></center>
			</fieldset>		
		</form>
		<div class="clear"></div>';
	}
	
	/**
	 * display Help
	 * 
     * @return string
	 */
	private function _displayHelp()
	{
		return '<p><b>'.$this->l('Welcome to the Zprofess!').'</b></p>
		<p>'.$this->l('This section will help you to understand how product average rating will be displayed on following pages 
			home featured product list, category product list, search result product list,  manufacturer product list .').'</p>
		<br />
		<p><b><u>1. '.$this->l('Product average rating will be displayed on following pages category product list, search result product list, manufacturer product list').'</u></b></p>
		<p>'.$this->l('Open file: /themes/prestashop/product-list.tpl').'</p>
		<p>'.$this->l('Insert code: {include file="$tpl_dir./../../modules/reviewratingsynthesis/themes/rating.tpl" product=$product}').'</p>
		<p>'.$this->l('Below: &lt;h3&gt;{if isset($product.new) && $product.new == 1} ...').'</p>
		<p>'.$this->l('Or Top: &lt;p class="product_desc" ...&gt;').'</p>
		<br />
		<p><b><u>2. '.$this->l('Product average rating will be displayed on home featured product list').'</u></b></p>
		<p>'.$this->l('Open file: /modules/homefeatured.tpl').'</p>
		<p>'.$this->l('Insert code: {include file="$tpl_dir./../../modules/reviewratingsynthesis/themes/rating.tpl" product=$product}').'</p>
		<p>'.$this->l('Below: &lt;h5&gt;&lt;a href="{$product.link}" ...').'</p>
		<br />
		';
	}
	
	/**
	 * get Rating Config
	 * 
	 * @return string
	 */
	public static function getRatingConfig()
	{
		self::$configRating['width'] 		= Configuration::get('ZPRO_WIDTH') != '' ? Configuration::get('ZPRO_WIDTH') : 'null';
		self::$configRating['cancel'] 		= Configuration::get('ZPRO_CANCEL') ? 'true' : 'false';
		self::$configRating['cancelHint'] 	=  Configuration::get('ZPRO_CANCEL_HINT');
		self::$configRating['cancelOff'] 	= Configuration::get('ZPRO_CANCEL_OFF');
		self::$configRating['cancelOn'] 	= Configuration::get('ZPRO_CANCEL_ON');
		self::$configRating['cancelPlace'] 	= Configuration::get('ZPRO_CANCEL_PLACE') ? 'left' : 'right';
		self::$configRating['half']			= Configuration::get('ZPRO_HALF') ? 'true' : 'false';
		
		//["bad", "poor", "regular", "good", "gorgeous"]
		$piecesArray = explode(",", Configuration::get('ZPRO_HINT_LIST'));
		$hintList = '[';
		for ($i = 0; $i < count($piecesArray); $i++) {
			$hintList .= '"' . $piecesArray[$i] . '"';
			if ($i != (count($piecesArray) - 1))
				$hintList .= ', ';
		}
		$hintList .= ']';
		self::$configRating['hintList'] = $hintList;
		
		self::$configRating['noRatedMsg'] 	= Configuration::get('ZPRO_NO_RATED_MSG');
		self::$configRating['number'] 		= Configuration::get('ZPRO_NUMBER');
		self::$configRating['path'] 		= Configuration::get('ZPRO_PATH');
		self::$configRating['iconRange'] 	= Configuration::get('ZPRO_ICON_RANGE');
		self::$configRating['starHalf'] 	= Configuration::get('ZPRO_STAR_HALF');
		self::$configRating['starOff'] 		= Configuration::get('ZPRO_STAR_OFF');
		self::$configRating['starOn']		= Configuration::get('ZPRO_STAR_ON');
		self::$configRating['start'] 		= Configuration::get('ZPRO_START');	
	}
	
	/**
	 * post Process
	 * 
	 * @return string
	 */
	public function postProcess()
	{		
		//Update values in DB for General Settings
		if (Tools::isSubmit('submitGeneralSettings')) {
			Configuration::updateValue('ZPRO_VALIDATED_BY_EMPLOYEE', (int)Tools::getValue('validated'));
			Configuration::updateValue('ZPRO_ALLOW_GUESTS', (int)Tools::getValue('allow_guest'));
			Configuration::updateValue('ZPRO_MINIMAL_TIME', ((int)(Tools::getValue('minimal_time') < 0 ? 0 : (int)Tools::getValue('minimal_time'))));
			Configuration::updateValue('ZPRO_ONLY_REVIEW', (int)Tools::getValue('only_review'));
			Configuration::updateValue('ZPRO_HOOK_RATING', (int)Tools::getValue('hook_rating'));
			Configuration::updateValue('ZPRO_HOOK_LATEST_REVIEWS', (int)Tools::getValue('latest_reviews'));
			Configuration::updateValue('ZPRO_NUMBER_LATEST_REVIEWS', (int)Tools::getValue('number_latest_reviews'));
			
			Configuration::updateValue('ZPRO_ENABLE_VOTE', (int)Tools::getValue('enable_vote'));
			Configuration::updateValue('ZPRO_HOOK_VOTE_MOST', (int)Tools::getValue('vote_most'));
			Configuration::updateValue('ZPRO_NUMBER_VOTE_MOST', (int)Tools::getValue('number_vote_most'));
			Configuration::updateValue('ZPRO_FB_SHARE', (int)Tools::getValue('fb_share'));
			
			echo $this->displayConfirmation($this->l('General Settings are updated'));
		}
		
		//Update values in DB for Rating Settings
		if (Tools::isSubmit('submitRatingSettings')) {
			if (isset($_FILES['star_off']) AND isset($_FILES['star_off']['tmp_name']) AND !empty($_FILES['star_off']['tmp_name'])) {
				if ($error = checkImage($_FILES['star_off'], $this->maxImageSize))
					return $this->displayError($this->l('invalid image'));
				else {
					if (!move_uploaded_file($_FILES['star_off']['tmp_name'], dirname(__FILE__).'/../img/upload/'.$_FILES['star_off']['name']))
						return $this->displayError($this->l('an error occurred on uploading file'));
					else {
						Configuration::updateValue('ZPRO_STAR_OFF', 'upload/'.$_FILES['star_off']['name']);
					}
				}
			}
			if (isset($_FILES['star_on']) AND isset($_FILES['star_on']['tmp_name']) AND !empty($_FILES['star_on']['tmp_name'])) {
				if ($error = checkImage($_FILES['star_on'], $this->maxImageSize))
					return $this->displayError($this->l('invalid image'));
				else {
					if (!move_uploaded_file($_FILES['star_on']['tmp_name'], dirname(__FILE__).'/../img/upload/'.$_FILES['star_on']['name']))
						return $this->displayError($this->l('an error occurred on uploading file'));
					else {
						Configuration::updateValue('ZPRO_STAR_ON', 'upload/'.$_FILES['star_on']['name']);
					}
				}
			}
			if (isset($_FILES['star_half']) AND isset($_FILES['star_half']['tmp_name']) AND !empty($_FILES['star_half']['tmp_name'])) {
				if ($error = checkImage($_FILES['star_half'], $this->maxImageSize))
					return $this->displayError($this->l('invalid image'));
				else {
					if (!move_uploaded_file($_FILES['star_half']['tmp_name'], dirname(__FILE__).'/../img/upload/'.$_FILES['star_half']['name']))
						return $this->displayError($this->l('an error occurred on uploading file'));
					else {
						Configuration::updateValue('ZPRO_STAR_HALF', 'upload/'.$_FILES['star_half']['name']);
					}
				}
			}
			if (isset($_FILES['cancel_off']) AND isset($_FILES['cancel_off']['tmp_name']) AND !empty($_FILES['cancel_off']['tmp_name'])) {
				if ($error = checkImage($_FILES['cancel_off'], $this->maxImageSize))
					return $this->displayError($this->l('invalid image'));
				else {
					if (!move_uploaded_file($_FILES['cancel_off']['tmp_name'], dirname(__FILE__).'/../img/upload/'.$_FILES['cancel_off']['name']))
						return $this->displayError($this->l('an error occurred on uploading file'));
					else {
						Configuration::updateValue('ZPRO_CANCEL_OFF', 'upload/'.$_FILES['cancel_off']['name']);
					}
				}
			}
			if (isset($_FILES['cancel_on']) AND isset($_FILES['cancel_on']['tmp_name']) AND !empty($_FILES['cancel_on']['tmp_name'])) {
				if ($error = checkImage($_FILES['cancel_on'], $this->maxImageSize))
					return $this->displayError($this->l('invalid image'));
				else {
					if (!move_uploaded_file($_FILES['cancel_on']['tmp_name'], dirname(__FILE__).'/../img/upload/'.$_FILES['cancel_on']['name']))
						return $this->displayError($this->l('an error occurred on uploading file'));
					else {
						Configuration::updateValue('ZPRO_CANCEL_ON', 'upload/'.$_FILES['cancel_on']['name']);
					}
				}
			}
			
			Configuration::updateValue('ZPRO_HINT_LIST', Tools::getValue('hint_list'));
			Configuration::updateValue('ZPRO_WIDTH', Tools::getValue('width'));
			Configuration::updateValue('ZPRO_CANCEL', Tools::getValue('cancel'));
			Configuration::updateValue('ZPRO_CANCEL_HINT', Tools::getValue('cancel_hint'));
			Configuration::updateValue('ZPRO_CANCEL_PLACE', Tools::getValue('cancel_place'));
			Configuration::updateValue('ZPRO_NUMBER', Tools::getValue('number'));
			Configuration::updateValue('ZPRO_HALF', Tools::getValue('half'));
			Configuration::updateValue('ZPRO_START', Tools::getValue('start'));
			
			echo $this->displayConfirmation($this->l('Rating Settings are updated'));
		}
		
		//Update values in DB for Rating Style Settings
		if (Tools::isSubmit('submitRatingStyle')) {
			Configuration::updateValue('ZPRO_CANCEL_HINT', 'cancel this rating!');
			Configuration::updateValue('ZPRO_CANCEL', 0);
			Configuration::updateValue('ZPRO_WIDTH', '');
			Configuration::updateValue('ZPRO_HALF', 0);
			Configuration::updateValue('ZPRO_START', 3);
			Configuration::updateValue('ZPRO_CANCEL_PLACE', 1);
			Configuration::updateValue('ZPRO_HINT_LIST', 'bad, poor, regular, good, gorgeous');
			Configuration::updateValue('ZPRO_NO_RATED_MSG', 'not rated yet');
			Configuration::updateValue('ZPRO_NUMBER', 5);
			Configuration::updateValue('ZPRO_PATH', $this->_path.'img/');
			Configuration::updateValue('ZPRO_ICON_RANGE', '[]');
			Configuration::updateValue('ZPRO_CANCEL_OFF', 'raty/cancel-off.png');
			Configuration::updateValue('ZPRO_CANCEL_ON', 'raty/cancel-on.png');
			Configuration::updateValue('ZPRO_STAR_HALF', 'raty/star-half.png');
			
			$style = (int)Tools::getValue('style');
			if($style == 1) {
				Configuration::updateValue('ZPRO_RATING_STYLE', 1);
				Configuration::updateValue('ZPRO_STAR_OFF', 'raty/star-off.png');
				Configuration::updateValue('ZPRO_STAR_ON', 'raty/star-on.png');
			} elseif($style == 2) {
				Configuration::updateValue('ZPRO_RATING_STYLE', 2);
				Configuration::updateValue('ZPRO_WIDTH', 160);	// featured
				Configuration::updateValue('ZPRO_CANCEL_OFF', 'raty/cancel-off-big.png');	// featured
				Configuration::updateValue('ZPRO_CANCEL_ON', 'raty/cancel-on-big.png');		// featured
				Configuration::updateValue('ZPRO_STAR_HALF', 'raty/star-half-big.png');		// featured
				Configuration::updateValue('ZPRO_STAR_OFF', 'raty/star-off-big.png');
				Configuration::updateValue('ZPRO_STAR_ON', 'raty/star-on-big.png');
			} elseif($style == 3) {
				Configuration::updateValue('ZPRO_RATING_STYLE', 3);
				Configuration::updateValue('ZPRO_STAR_OFF', 'raty/medal-off.png'); 
				Configuration::updateValue('ZPRO_STAR_ON', 'raty/medal-on.png');
			} elseif($style == 4) {
				Configuration::updateValue('ZPRO_RATING_STYLE', 4);
				Configuration::updateValue('ZPRO_ICON_RANGE', '[["raty/face-a.png", 2], ["raty/face-b.png", 3], ["raty/face-c.png", 4], ["raty/face-d.png", 5]]'); // featured
				Configuration::updateValue('ZPRO_STAR_OFF', 'raty/face-off.png'); 
				Configuration::updateValue('ZPRO_STAR_ON', 'raty/face-c.png'); 
				Configuration::updateValue('ZPRO_START', 0);	// featured
			}
			
			echo $this->displayConfirmation($this->l('Rating Settings are updated'));
		}
		
		//Update values in DB for Review Settings
		if (Tools::isSubmit('submitReviewSettings')) {
			Configuration::updateValue('ZPRO_ENABLE_EMAIL', (int)Tools::getValue('enable_email'));
			Configuration::updateValue('ZPRO_ENABLE_WEBSITE', (int)Tools::getValue('enable_website'));
			Configuration::updateValue('ZPRO_DISPLAY_EMAIL', (int)Tools::getValue('display_email'));
			Configuration::updateValue('ZPRO_DISPLAY_WEBSITE', (int)Tools::getValue('display_website'));
			Configuration::updateValue('ZPRO_DISPLAY_TITLE', (int)Tools::getValue('display_title'));
		
			echo $this->displayConfirmation($this->l('Review Settings are updated'));
		}
		
		//Update values in DB for Captcha Settings
		if (Tools::isSubmit('submitCaptchaSettings')) {
			Configuration::updateValue('ZPRO_ENABLE_CAPTCHA', Tools::getValue('enable_captcha'));
			Configuration::updateValue('ZPRO_HEIGHT_IMG', Tools::getValue('height_img'));
			Configuration::updateValue('ZPRO_WIDTH_IMG', Tools::getValue('width_img'));
			Configuration::updateValue('ZPRO_BG_COLOR', Tools::getValue('bg_color'));
			Configuration::updateValue('ZPRO_TEXT_COLOR', Tools::getValue('text_color'));
			Configuration::updateValue('ZPRO_LINE_COLOR', Tools::getValue('line_color'));
			Configuration::updateValue('ZPRO_CODE_LENGTH', Tools::getValue('code_length'));
			Configuration::updateValue('ZPRO_NUMBER_LINE', Tools::getValue('number_line'));
			Configuration::updateValue('ZPRO_SIGNATURE_TEXT', Tools::getValue('signature_text'));
			Configuration::updateValue('ZPRO_SIGNATURE_COLOR', Tools::getValue('signature_color'));
		
			echo $this->displayConfirmation($this->l('Captcha Settings are updated'));
		}
		
			//Update values in DB for Email Settings
		if (Tools::isSubmit('submitEmailSettings')) {
			Configuration::updateValue('ZPRO_ENABLE_EMAIL_NOTIFICATION', Tools::getValue('enable_email_notification'));
			Configuration::updateValue('ZPRO_EMAIL_NOTIFICATION', Tools::getValue('email_notification'));
			Configuration::updateValue('ZPRO_EMAIL_SUBJECT', Tools::getValue('email_subject'));
			Configuration::updateValue('ZPRO_EMAIL_TEMPLATE', Tools::getValue('email_tempalte'), true);
			
			echo $this->displayConfirmation($this->l('Email Settings are updated'));
		}
	}
	
	/**
	 * display Form
	 * 
	 * @return string
	 */
 	public function displayForm()
 	{ 	
 		
 		$this->_displayFormConfig();
 		$this->_displaySupport();
 		return $this->_html;
	}
}